//
//  YCVCsUnWindTransition.m
//  DemoTransition
//
//  Created by yunsheng on 15/7/23.
//  Copyright (c) 2015年 yunsheng. All rights reserved.
//

#import "YCVCsUnWindTransition.h"

@implementation YCVCsUnWindTransition

-(void)perform
{
    UIView *fromVCView = ((UIViewController *)self.sourceViewController).view;
    UIView *toVCView = ((UIViewController *)self.destinationViewController).view;
    
    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:toVCView];
    [window addSubview:fromVCView];
    toVCView.frame = fromVCView.frame;
    
    [UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:0 options:UIViewAnimationOptionCurveLinear animations:^{
        fromVCView.frame = CGRectOffset(fromVCView.frame, 0.0, screenHeight);
    } completion:^(BOOL finished) {
        [self.sourceViewController dismissViewControllerAnimated:NO completion:nil];
    }];
}

@end
